-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Support rename tag action and procedure #4277
Conversation
<td> | ||
CALL sys.rename_tag(table => 'default.T', tag_name => 'tag1', new_tag_name => 'tag2') | ||
</td> | ||
</tr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_name
will be better ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
try { | ||
if (!tagExists(tagName)) { | ||
throw new RuntimeException(String.format("tag: %s is not exists", tagName)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specified tag name [%s] does not exist ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import java.util.Optional; | ||
|
||
/** Factory to create {@link RenameActionFactory}. */ | ||
public class RenameActionFactory implements ActionFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RenameTagActionFactory ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
public void run() throws Exception { | ||
if (StringUtils.isEmpty(tagName) || StringUtils.isEmpty(newTagName)) { | ||
throw new RuntimeException(String.format("tagName or newTagName can not be empty")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.format("The specified tag name [%s] or target tag name [%s] cannot be empty.", tagName, targetName)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
throws Catalog.TableNotExistException { | ||
Table table = catalog.getTable(Identifier.fromString(tableId)); | ||
table.renameTag(tagName, newTagName); | ||
return new String[] {"Success"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return : Rename [%s] to [%s] successfully .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Thanks for @LinMingQiang review. Had addressed comments. |
+1 |
docs/content/spark/procedures.md
Outdated
<tr> | ||
<td>rename_tag</td> | ||
<td> | ||
Rename tag to new tag name. Arguments: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename a tag with a new tag name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
docs/content/spark/procedures.md
Outdated
<tr> | ||
<td>rename_tag</td> | ||
<td> | ||
Rename tag to new tag name. Arguments: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename a tag with a new tag name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import java.util.Optional; | ||
|
||
/** Factory to create {@link RenameActionTagFactory}. */ | ||
public class RenameActionTagFactory implements ActionFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RenameTagActionFactory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/** Factory to create {@link RenameActionTagFactory}. */ | ||
public class RenameActionTagFactory implements ActionFactory { | ||
|
||
public static final String IDENTIFIER = "rename_tag"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
@Override | ||
public void printHelp() { | ||
System.out.println("Action \"rename_tag\" rename a tag with a new tagname."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: In word 'tagname'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import org.apache.flink.table.procedure.ProcedureContext; | ||
|
||
/** | ||
* Create tag procedure. Usage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create tag procedure?
argument = { | ||
@ArgumentHint(name = "table", type = @DataTypeHint("STRING")), | ||
@ArgumentHint(name = "tagName", type = @DataTypeHint("STRING")), | ||
@ArgumentHint(name = "targetTagName", type = @DataTypeHint("STRING")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* </code></pre> | ||
*/ | ||
public class RenameTagProcedure extends ProcedureBase { | ||
public static final String IDENTIFIER = "rename_tag"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
docs/content/spark/procedures.md
Outdated
Rename tag to new tag name. Arguments: | ||
<li>table: the target table identifier. Cannot be empty.</li> | ||
<li>tag_name: name of the tag. Cannot be empty.</li> | ||
<li>target_tag_name: the new tag name to rename.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_tag_name: the new tag name to rename. Cannot be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Why you need this feature? |
Change title to :"Support rename tag action and procedure."; |
Yes, if user want to modify tag name which was not normative need the feature. Currently user cannot rename tag in a direct way, and if snapshot expire user cannot rename tag any more. @wwj6591812 |
Thanks for @wwj6591812 review, had addressed comments. |
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Purpose
Currently tag can not rename after create,this pr is aim to support it.
Linked issue: close #xxx
Tests
API and Format
Documentation